package com.wwf;

import com.wwf.Contro.TestTpContro;
import com.wwf.filter.com.wwf.util.TpCount;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

@Configuration
@EnableDubbo
@ComponentScan("com.wwf.Contro")
@PropertySource("classpath:/dubbo-consumer.properties")
public class TpConsumerMain {
    public static void main(String[] args) throws InterruptedException {
        AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(TpConsumerMain.class);
        annotationConfigApplicationContext.start();
            ExecutorService executorService = Executors.newFixedThreadPool(5);
       /* Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay(new Runnable() {
            @Override
            public void run() {
                // System.out.println("sdsdsd");
                TpCount.reportTp();
            }
        },1,5, TimeUnit.SECONDS);*/
            while (true){
                executorService.submit(new Runnable() {
                    @Override
                    public void run() {
                        TestTpContro testTpContro = (TestTpContro)annotationConfigApplicationContext.getBean("testTpContro");
                        String rs = testTpContro.testA("a1");
                        String rs1 = testTpContro.testB("B1");
                        String rs2 = testTpContro.testC("C1");
                        //System.out.println(rs);
                    }
                });
                Thread.sleep(20);
            }


    }
}
